package com.cysion.study.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.cysion.study.R
import com.cysion.study.entity.CourseDayEntity
import com.cysion.study.ktbox.base.BaseAdapter
import com.cysion.study.ktbox.base.BaseViewHolder
import com.cysion.study.ktbox.base.ITEM_CLICK
import com.cysion.study.widget.TimeUtil.converToStandardTime
import kotlinx.android.synthetic.main.item_day_course.view.*

class DayCourseAdapter(mEntities: MutableList<CourseDayEntity>, mContext: Context) :
    BaseAdapter<CourseDayEntity>(mEntities, mContext) {

    companion object {

        //点击事件
        const val refuse = 2000
        const val agree = 2001
    }

    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): BaseViewHolder<CourseDayEntity> {
        return ProMoneyHolder(
            LayoutInflater.from(mContext).inflate(R.layout.item_day_course, parent, false)
        )
    }

    class ProMoneyHolder(itemView: View) : BaseViewHolder<CourseDayEntity>(itemView) {
        override fun fillData(obj: CourseDayEntity, position: Int) {
            itemView?.apply {
                tv_time.text =
                    converToStandardTime(obj?.startTime) + "--" + converToStandardTime(obj?.endTime)
                tv_num.text = obj.currentNumber + "/" + obj.totalNumber

                tv_address.text = obj.address

                //type":0//类型 0.托管课程 1.课程 2.活动安排 3.研学安排
                if (obj.type == "0") {
                    tv_title.text = "托管：" + obj.researchName
                } else {
                    tv_title.text = obj.researchName
                }
                itemView.setOnClickListener {
                    mOnTypeClickListener?.invoke(obj, position, ITEM_CLICK)
                }

                //isRead":0, //是否已读 0.未读 1.已读
                /*tv_agree._setOnClickListener {
                    //当通知需要确认时必填 1.同意 2.拒绝
                    mOnTypeClickListener?.invoke(obj, position, agree)
                }
                tv_refuse._setOnClickListener {
                    mOnTypeClickListener?.invoke(obj, position, refuse)
                }*/
            }
        }

    }
}